﻿@model Senparc.Weixin.MP.Helpers.JsSdkUiPackage
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>JsSDK</title>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script>
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: '@Model.AppId', // 必填，公众号的唯一标识
            timestamp: '@Model.Timestamp', // 必填，生成签名的时间戳
            nonceStr: '@Model.NonceStr', // 必填，生成签名的随机串
            signature: '@Model.Signature',// 必填，签名
            jsApiList: [
                'checkJsApi',
                'onMenuShareTimeline',
                'onMenuShareAppMessage',
                'onMenuShareQQ',
                'onMenuShareWeibo',
                'onMenuShareQZone',
                'hideMenuItems',
                'showMenuItems',
                'hideAllNonBaseMenuItem',
                'showAllNonBaseMenuItem',
                'translateVoice',
                'startRecord',
                'stopRecord',
                'onVoiceRecordEnd',
                'playVoice',
                'onVoicePlayEnd',
                'pauseVoice',
                'stopVoice',
                'uploadVoice',
                'downloadVoice',
                'chooseImage',
                'previewImage',
                'uploadImage',
                'downloadImage',
                'getNetworkType',
                'openLocation',
                'getLocation',
                'hideOptionMenu',
                'showOptionMenu',
                'closeWindow',
                'scanQRCode',
                'chooseWXPay',
                'openProductSpecificView',
                'addCard',
                'chooseCard',
                'openCard'
            ]
        });

        wx.ready(function() {
            //这里调用具体的js-sdk接口方法
            document.querySelector('#chooseImage').onclick = function () {
                wx.chooseImage({
                    success: function (res) {
                        $("#chooseImg").attr("src", res.localIds);
                        alert('你选择的照片信息： ' + res.localIds.length);
                    }
                });
            };
           });

        wx.error(function (res) {
            console.log(res);
            alert('验证失败');
        });
    </script>

</head>
<body>
    <h1>公众号JSSDK演示</h1>
    <button id="chooseImage">打开相册</button>
    <img src="" alt="image" id="chooseImg" width="80%" height="200px" />
</body>
</html>
